package com.neuedu.autosale.purchase.service.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.autosale.entity.Pager;
import com.neuedu.autosale.entity.Result;
import com.neuedu.autosale.mapper.RestockMapper;
import com.neuedu.autosale.purchase.entity.Restock;
import com.neuedu.autosale.purchase.service.RestockService;

@Service
@Transactional
public class RestockServiceImpl implements RestockService{

	@Autowired
	private RestockMapper restockMapper;
	
	@Override
	public List<Restock> findListByPager(Pager<Restock> pager) {
		
		return restockMapper.findListBypager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Restock> pager) {
		
		return restockMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Restock object) {
		
		Result result = new Result(false, "新增失败！");
		boolean ret = restockMapper.add(object);
		if (ret) {
			result = new Result(true, "新增成功！");
		}
		return result;
	}

	@Override
	public Result edit(Restock object) {
	
		Result result = new Result(false, "修改失败！");
		boolean ret = restockMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改成功！");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Restock> ids) {
		Result result = new Result(false, "删除失败！");
		boolean ret = restockMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除成功！");
		}
		return result;
	}

	@Override
	public List<Restock> findAll() {
		return restockMapper.findAll();
	}

}
